import numpy as np
import numpy.linalg as nla
import matplotlib.pyplot as plt
import nibabel as nib
import os
%matplotlib inline
path = '/home/snarles/predator'
#os.listdir(path + '/8631_5_1_pfile/coil_images')
bvecs = np.loadtxt(path + '/chris1_bvec.csv', delimiter = ' ').T
b0_inds = list(np.where(np.array([nla.norm(v) for v in bvecs]) == 0)[0])
b0_inds
c0 = nib.load(path + '/8631_5_1_pfile/coil_images/coil_comb_ec.nii.gz').get_data()
c0 = c0[:, :, :, b0_inds]
c0_mu = np.mean(c0, axis = 3)
figsize_ = (3, 3)
z_inds = [10, 20, 30, 40, 50]
np.min(c0[:, :, :, 2][:] - c0_mu[:]), np.max(c0[:, :, :, 2][:] - c0_mu[:])
vmin_2 = -20.0
vmax_2 = 10.0
w_inds = range(10)
#z_inds = [12, 14, 16, 18, 20]
figsize_2 = (len(z_inds) * figsize_[0], len(w_inds) * figsize_[1])
f_c1, axarr = plt.subplots(len(w_inds), len(z_inds), sharex=True, sharey=True, figsize = figsize_2)
for i in range(len(w_inds)):
w_ind = w_inds[i]
for j in range(len(z_inds)):
z_ind = z_inds[j]
axarr[i, j].imshow(c0[:, :, z_ind, w_ind] - c0_mu[:, :, z_ind], cmap='bone', vmin = vmin_2, vmax = vmax_2)
vmin_2 = -20.0
vmax_2 = 10.0
w_inds = range(10)
z_inds = [18, 19, 20, 21, 22, 23, 24, 25, 26]
figsize_2 = (len(z_inds) * figsize_[0], 2 * len(w_inds) * figsize_[1])
f_c1, axarr = plt.subplots(len(w_inds), len(z_inds), sharex=True, sharey=True, figsize = figsize_2)
for i in range(len(w_inds)):
w_ind = w_inds[i]
for j in range(len(z_inds)):
z_ind = z_inds[j]
axarr[i, j].imshow(c0[:, :60, z_ind, w_ind] - c0_mu[:, :60, z_ind], cmap='bone', vmin = vmin_2, vmax = vmax_2)
vmin_2 = -20.0
vmax_2 = 10.0
w_inds = range(10)
z_inds = [18, 19, 20, 21, 22, 23, 24, 25, 26]
figsize_2 = (len(z_inds) * figsize_[0], 2 * len(w_inds) * figsize_[1])
f_c1, axarr = plt.subplots(len(z_inds), len(w_inds), sharex=True, sharey=True, figsize = figsize_2)
for i in range(len(w_inds)):
w_ind = w_inds[i]
for j in range(len(z_inds)):
z_ind = z_inds[j]
axarr[j, i].imshow(c0[:, :60, z_ind, w_ind] - c0_mu[:, :60, z_ind], cmap='bone', vmin = vmin_2, vmax = vmax_2)